/*
2021-7-29
https://www.acwing.com/problem/content/3787/
*/
#include<cstring>
#include<iostream>
#include<algorithm>

using namespace std;
const int N=2e5+5;
int a[N];
char s[N];
int n;

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    cin>>s+1;
    
    int maxv=-1;
    bool flag=true;
    for(int i=1;i<n;i++)
    {
        maxv=max(maxv,a[i]);
        if(s[i]=='0' && maxv!=i)
            flag=false;
    }
    
    if(flag) puts("YES");
    else puts("NO");
    
    return 0;
}


 
